package com.thread.view;

import org.junit.Test;

import java.io.*;

public class Test01 {

    public static void main(String[] args) throws Exception {
        System.out.println(File.separator);
        File file = new File("D:" + File.separator + "test.txt");
        //文件字节流
        FileOutputStream outputStream = new FileOutputStream(file);
        String str = "hello Warld";
        byte[] bytes = str.getBytes();
        outputStream.write(bytes);
        outputStream.close();
    }

    @Test
    public void test001() throws Exception {
        File file = new File("D:" + File.separator + "test.txt");
        FileInputStream inputStream = new FileInputStream(file);
        byte[] buf = new byte[1024];
        while ((inputStream.read(buf, 0, 1024)) != -1) { //将数据最多1024个字节读到缓冲区数组buf中
            System.out.println(new String(buf));
        }
        inputStream.close();
    }


}
